package com.xyzq.model.ya.data;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.appfuse.model.BaseObject;

@Entity
@Table(name = "account_profit")
public class AccountMonthProfit extends BaseObject implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 9025546367675499377L;
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "FK_ACCOUNT_ACCOUNT", nullable = false)
	private Account account;
	@Column(scale = 2)
	private Double deal;
	@Column(scale = 2)
	private Double profit;
	@Column(name = "pure_profit", scale = 2)
	private Double pureProfit;
	@Column(name = "profit_rate", scale = 2)
	private Double profitRate;
	@Column(name = "pure_profit_rate", scale = 2)
	private Double pureProfitRate;
	private String month;
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "sub_time")
	private Date subTime;

	public void setAccountId(Integer accountId) {
		if(account==null){
			account=new Account();
		}
		this.account.setAccount(accountId);
	}

	public Long getId() {
		return id;
	}

	public Account getAccount() {
		return account;
	}

	public Double getDeal() {
		return deal;
	}

	public Double getProfit() {
		return profit;
	}

	public String getMonth() {
		return month;
	}

	public Date getSubTime() {
		return subTime;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setAccount(Account account) {
		this.account = account;
	}

	public void setDeal(Double deal) {
		this.deal = deal;
	}

	public void setProfit(Double profit) {
		this.profit = profit;
	}

	public void setMonth(String month) {
		this.month = month;
	}

	public void setSubTime(Date subTime) {
		this.subTime = subTime;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((account == null) ? 0 : account.hashCode());
		result = prime * result + ((deal == null) ? 0 : deal.hashCode());
		result = prime * result + ((month == null) ? 0 : month.hashCode());
		result = prime * result + ((profit == null) ? 0 : profit.hashCode());
		result = prime * result
				+ ((profitRate == null) ? 0 : profitRate.hashCode());
		result = prime * result
				+ ((pureProfit == null) ? 0 : pureProfit.hashCode());
		result = prime * result
				+ ((pureProfitRate == null) ? 0 : pureProfitRate.hashCode());
		result = prime * result + ((subTime == null) ? 0 : subTime.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		AccountMonthProfit other = (AccountMonthProfit) obj;
		if (account == null) {
			if (other.account != null)
				return false;
		} else if (!account.equals(other.account))
			return false;
		if (deal == null) {
			if (other.deal != null)
				return false;
		} else if (!deal.equals(other.deal))
			return false;
		if (month == null) {
			if (other.month != null)
				return false;
		} else if (!month.equals(other.month))
			return false;
		if (profit == null) {
			if (other.profit != null)
				return false;
		} else if (!profit.equals(other.profit))
			return false;
		if (profitRate == null) {
			if (other.profitRate != null)
				return false;
		} else if (!profitRate.equals(other.profitRate))
			return false;
		if (pureProfit == null) {
			if (other.pureProfit != null)
				return false;
		} else if (!pureProfit.equals(other.pureProfit))
			return false;
		if (pureProfitRate == null) {
			if (other.pureProfitRate != null)
				return false;
		} else if (!pureProfitRate.equals(other.pureProfitRate))
			return false;
		if (subTime == null) {
			if (other.subTime != null)
				return false;
		} else if (!subTime.equals(other.subTime))
			return false;
		return true;
	}

	@Override
	public String toString() {
		ToStringBuilder builder = new ToStringBuilder(this,
				ToStringStyle.DEFAULT_STYLE);
		builder.append("id", id);
		builder.append("account", account);
		builder.append("deal", deal);
		builder.append("profit", profit);
		builder.append("pureProfit", pureProfit);
		builder.append("profitRate", profitRate);
		builder.append("pureProfitRate", pureProfitRate);
		builder.append("month", month);
		builder.append("subTime", subTime);
		return builder.toString();
	}

	public void setPureProfit(Double pureProfit) {
		this.pureProfit = pureProfit;
	}

	public Double getPureProfit() {
		return pureProfit;
	}

	public void setPureProfitRate(Double pureProfitRate) {
		this.pureProfitRate = pureProfitRate;
	}

	public Double getPureProfitRate() {
		return pureProfitRate;
	}

	public void setProfitRate(Double profitRate) {
		this.profitRate = profitRate;
	}

	public Double getProfitRate() {
		return profitRate;
	}

}
